/**
 * 用户能力模型
 */
$(function(){
	webUtils.nameSpace("wiseMen.platform.userAbility");
	
	wiseMen.platform.userAbility.add=function(treeTpl,nodes,queryDefTpl){
		if (nodes && nodes.length > 0) {
			var node=nodes[0];
			var uuid=webUtils.uuid();
			var d=webUtils.dialog({
				url:ctx+"/dataModelDefAct/editTpl.do?dms=PF_USER_ABILITY&PF_USER_ABILITY_PID="+node.ID+"&winId="+uuid,
				onremove:function(){
					webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
				}
			});
			webUtils.on("dialog.submit.success."+uuid,function(data){
				treeTpl.reAsyncChildNodes(treeTpl.getNodesByParam("ID", node.ID)[0], "refresh");
				d.close();
			},true);
		}else{
			webUtils.alert("请选择其中一项");
		}
	}
	wiseMen.platform.userAbility.mod=function(treeTpl,nodes,queryDefTpl){
		if (nodes && nodes.length > 0) {
			var node=nodes[0];
			var uuid=webUtils.uuid();
			var d=webUtils.dialog({
				url:ctx+"/dataModelDefAct/editTpl.do?dms=PF_USER_ABILITY&PF_USER_ABILITY_ID="+node.ID+"&winId="+uuid,
				onremove:function(){
					webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
				}
			});
			webUtils.on("dialog.submit.success."+uuid,function(data){
				treeTpl.reAsyncChildNodes(treeTpl.getNodesByParam("ID", node.PID)[0], "refresh");
				d.close();
			},true);
		}else{
			webUtils.alert("请选择其中一项");
		}
	}
	wiseMen.platform.userAbility.view=function(treeTpl,nodes,queryDefTpl){
		if (nodes && nodes.length > 0) {
			var node=nodes[0];
			var uuid=webUtils.uuid();
			var d=webUtils.dialog({
				url:ctx+"/dataModelDefAct/viewTpl.do?dms=PF_USER_ABILITY&PF_USER_ABILITY_ID="+node.ID+"&winId="+uuid,
				onremove:function(){
				}
			});
		}else{
			webUtils.alert("请选择其中一项");
		}
	}
	wiseMen.platform.userAbility.del=function(treeTpl,nodes,queryDefTpl){
		webUtils.confirm("删除数据将不可恢复，是否继续！",function(r){
			if(r){
				if (nodes && nodes.length > 0) {
					var node=nodes[0];

					$.post(ctx + "/formDataAction/delByIds.do", {tableName:"PF_USER_ABILITY",ids: node.ID}, function (data) {
		                if (data.success) {
		                	treeTpl.reAsyncChildNodes(treeTpl.getNodesByParam("ID", node.PID)[0], "refresh");
		                } else {
		                	webUtils.error(data.msg);
		                }
		            }, 'json');
				}else{
					webUtils.alert("请选择其中一项");
				}
				
			}
		});
		
	}
});